package com.zzq.my.jetpacks.jectpackapp.ui.act

import android.util.Log
import by.kirich1409.viewbindingdelegate.viewBinding
import com.aisier.architecture.base.BaseActivity
import com.zzq.my.jetpacks.jectpackapp.R
import com.zzq.my.jetpacks.jectpackapp.adapter.RvAdapter
import com.zzq.my.jetpacks.jectpackapp.bean.ItemInfo
import com.zzq.my.jetpacks.jectpackapp.databinding.ActivityCoordinatorlayoutBinding
import com.zzq.my.jetpacks.util.async
import com.zzq.my.jetpacks.util.await

/**
 * 描述：CoordinatorLayout 协调者布局
 * 作者：zhuangzeqin
 * 时间: 2022/1/18-17:04
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class CoordinatorLayoutAct : BaseActivity(R.layout.activity_coordinatorlayout) {
    private val vb by viewBinding(ActivityCoordinatorlayoutBinding::bind)
    private lateinit var rvAdapter: RvAdapter
    /**
     * 初始化数据
     */
    override fun initData() {
        rvAdapter = RvAdapter()
        val mutableListOf = mutableListOf<ItemInfo>()
        val listOf = listOf(
            "网络请求封装",
            "ConcatAdapter合并多个rv适配器",
            "androidx Fragment 懒加载",
            "FlexboxLayout弹性布局",
            "Rxhttp 网络请求封装",
            "ShapeView阴影基本用法",
            "MMKV 的基本使用",
            "Flow 的基本是使用",
            "fresco 强大的图片加载框架",
            "APP 引导页",
            "fresco 强大的图片加载框架",
            "ActivityMessenger简化Activity之间传参和回调的逻辑代码。",
            "step指示器动态添加",
            "到账方式",
            "账号提现",
            " 实现带空格分隔的输入电话号码",
            " NestedScrollView滚动到顶部固定子View悬停挂靠粘在顶端",
            " ViewPager listView 滑动冲突解决",
            " Scrollview rv 滑动冲突解决",
            " HeaderScrollViewActivity 吸顶",
            " PlayLoadingAct 支付页面",
            " PlayStatusAct 支付状态页面",
            " PlayTickAct 签购小票",
            " BottomSheetActivity",
            " ShapeableImageViewActivity",
            " ViewPager2 轮播图",
            " GrowUpCenterAct 成长中心",
            " ReclyeView 网格线分隔",
            " CoordinatorLayout 管理子View或者子View之间的联动交互",
        )
        listOf.forEach {
            mutableListOf.add(ItemInfo(it))
        }
        rvAdapter.setList(mutableListOf)
        vb.rvChild.adapter = rvAdapter
    }

    /**
     * 初始化操作
     */
    override fun initView() {
//        lifecycleScope.launch {
//            runCatching {
//                coroutineScope {
//                    val result = 10/0
//                    result
//                }
//            }.onFailure {
//                it.printStackTrace()
//            }
//        }

        async {
            val result = 10/0
            result
        }.await(onSuccess = {
            Log.d(TAG, "initView: onSuccess")
        }, onError = {
            Log.d(TAG, "initView: onError")
        },onComplete = {
            Log.d(TAG, "initView: onComplete")
        }
        )
    }

    /**
     * 初始化点击事件操作
     */
    override fun eventOnClick() {

    }


}